<?php
/**
 * Hält Streckendaten.
 * @author Timo
 */
class Track {
    private $name          = 'Unknown';
    private $length_km     = 0;
    private $laps          = 0;
    private $location      = 'Unknown';
    private $lastWinner    = 0; // ID des Fahrers
    private $hotlap        = 0; // Angabe in Sekunden -> Wird später auf anderes Format (--:--.---) umgerechnet.
    private $hotlap_owner  = 0; // ID des Fahrers

    function Track($name)
    {
        if(is_string($name))
        {
            $this->SetName($name);
        }
        else
        {
            echo $name . ' is not a string.';
        }
    }

    public function SetName($name)
    {
        if(is_string($name))
        {
            $this->name = $name;
        }
        else
        {
            echo $name . ' is not a string.';
        }
    }

    public function SetLenght($km)
    {
        if(is_numeric($km))
        {
            $this->length_km = $km;
        }
        else
        {
            echo $km . ' is not a number.';
        }
    }

    public function SetLocation($loc)
    {
        if(is_string($loc))
        {
            $this->location = $loc;
        }
        else
        {
            echo $loc . ' is not a string.';
        }
    }

    public function SetLaps($laps)
    {
        if(is_integer($laps))
        {
            $this->laps = $laps;
        }
        else
        {
            echo $laps . ' is not an integer.';
        }
    }

    public function SetLastWinner($winner)
    {
        if(is_string($winner))
        {
            $this->lastWinner = $winner;
        }
        else
        {
            echo $winner . ' is not a string.';
        }
    }

    public function SetHotlap($sec) // e.g. "--:--.--"
    {
        if(is_integer($sec))
        {
            $this->hotlap = $sec;
        }
        else
        {
            echo $sec . ' is not an integer.';
        }
    }

    public function GetName()
    {
        return $this->name;
    }

    public function GetLength()
    {
        return $this->length;
    }

    public function GetLocation()
    {
        return $this->location;
    }

    public function GetLaps()
    {
        return $this->laps;
    }

    public function GetLastWinner()
    {
        return $this->lastWinner;
    }

    public function GetHotlap()
    {
        return $this->hotlap;
    }
}
?>
